#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
using namespace std;

class Solution {
public:
    int triangleNumber(vector<int>& nums) {
        sort(nums.begin(), nums.end());
        int num = 0;
        int len = nums.size();
        for (int i = len - 1; i >= 2; i--)
        {
            int left = 0;
            int right = i - 1;
            while (left < right)
            {
                if (nums[left] + nums[right] > nums[i])
                {
                    num += (right - left);
                    right--;
                }
                else
                {
                    left++;
                }
            }

        }
        return num;
    }
};


int main()
{
	return 0;
}
